#include "main/utils.h"
using namespace std;

class Solution {
public:
    vector<string> getFolderNames(vector<string>& names) {
      map<string, int> help_map;
      vector<string> new_names;
      for (auto name : names) {
        if (help_map.find(name) == help_map.end()) {
          new_names.push_back(name);
          help_map[name] = 0;
          continue;
        }
        int postfix = help_map[name] + 1;
        string new_name = name + "(" + to_string(postfix) + ")";
        while (help_map.find(new_name) != help_map.end()) {
          ++postfix;
          new_name = name + "(" + to_string(postfix) + ")";
        }
        new_names.push_back(new_name);
        help_map[new_name] = 0;
        help_map[name] = postfix;
      }
      return new_names;
    }
};

int main() {
  vector<string> names = {"kaido","kaido(1)","kaido","kaido(1)","kaido(2)"};
  Solution su;
  auto new_names = su.getFolderNames(names);
  printVec("leetcode1487", new_names);

  return 0;
}
